﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using System.Net;
using System.Net.Sockets;
using System.Globalization;
using System.Collections.ObjectModel;
using System.Threading;
using System.Configuration;


namespace BNet_Bot
{
    public class BNCSPacket : DataBuffer
    {
        byte packetId;

        public BNCSPacket(byte id)
        {
            mStream = new MemoryStream();
            packetId = id;
        }

        public override byte[] GetBuffer()
        {
            byte[] thisBuffer = mStream.GetBuffer();
            DataBuffer tempBuffer = new DataBuffer();
            tempBuffer.AddByte(0x01);
            tempBuffer.AddByte(0xFF);
            tempBuffer.AddByte(this.packetId);
            tempBuffer.AddInt16((short)(thisBuffer.Length + tempBuffer.GetBuffer().Length + 4));
            tempBuffer.AddByteArray(thisBuffer);
            return tempBuffer.GetBuffer();
        }
    }
}
